#include <iostream>
#include <string>
#include <iomanip>
using namespace std;
class InvoiceItem
{
private:
	string desc;
	int storage,price;
public:
	void setStorage(int u)
	{
		storage=u;
	}
	string getDescription()
	{
		return desc;
	}
	void setDescription(string d)
	{
		desc=d;
	}
	int getStorage()
	{
		return storage;
	}
	void setPrice(int p)
	{
		price=p;
	}
	float getPrice()
	{
		return (float)price;
	}
};
class SaleSyetem
{
private:
	InvoiceItem item[101];
	int top,num;
	float profit,tax,price,total;
public:
	SaleSyetem()
	{
		num=-1;
		top=0;
	}
	bool buy(string name,int number)
	{
		num=-1;
		if(number<0)
			return false;
		for(int i=0;i<=top;i++)
			if(item[i].getDescription()==name)
				num=i;
		if(num==-1)
			return false;
		if(item[num].getStorage()-num<0)
			return false;
		price=item[num].getPrice();
		item[num].setStorage(item[num].getStorage()-number);
		price*=1.3;
		total=price*number;			//小计
		tax=total*0.06;				//零售税
		price=total+tax;			//销售额
		cout<<"You bought "<<number<<" "<<name<<"s"<<endl;
		cout<<"The price is "<<total<<", the tax is "<<tax<<" ,and the total price is "<<price<<"."<<endl;
		return true;
	}
	bool add(string name,int number,int price)
	{
		if(top==100)
			return false;
		for(int i=0;i<=top;i++)
			if(item[i].getDescription()==name)
			{
				item[i].setStorage(item[i].getStorage()+number);
				return true;
			}	
		top++;
		item[top].setStorage(number);
		item[top].setPrice(price);
		item[top].setDescription(name);
		return true;
	}
};
int main()
{
	SaleSyetem customer;
	string opration;
	string name;
	int number,price;
	while(1)
	{
		cin>>opration;
		if(opration=="exit")
			break;
		else if(opration=="buy")
		{
			cout<<"Input the thing you want to buy:";
			cin>>name;
			cout<<"How much "<<name<<" do you want to buy?";
			cin>>number;
			if(!customer.buy(name,number))
				cout<<"Failed!"<<endl;
		}
		else if(opration=="add")
		{
			cout<<"Input the name of the item:";
			cin>>name;
			cout<<"Input the price:";
			cin>>price;
			cout<<"Input the number:";
			cin>>number;
			if(!customer.add(name,number,price))
				cout<<"Adding failed!"<<endl;
		}
		else
			cout<<"Input Error";
	}
	return 0;
}